#ifndef SEGMENT_H
#define SEGMENT_H

#include "point.h"

class segment
{
    public:
        segment();
        segment(const point &a, const point &b);

        int left_turn(const point& p) const;
        int further(const point& p1, const point& p2) const;

        point a, b;
    private:
        int left_turn_epsilon(const point& p) const;
        int left_turn_gmp(const point& p) const;

        int further_epsilon(const point& p1, const point& p2) const;
        int further_gmp(const point& p1, const point& p2) const;
};

class left_turn_predicate
{
    public:
        left_turn_predicate(const segment &s): s(s)
        {
        }

        bool operator()(const point &p) const
        {
            return s.left_turn(p) > 0;
        }
    private:
        segment s;
};

class distance_comparator
{
    public:
        distance_comparator(const segment &s): s(s)
        {
        }

        bool operator()(const point &a, const point &b) const
        {
            return s.further(a, b) < 0;
        }
    protected:
        segment s;
};

#endif
